import { createStore } from 'vuex'
import {getphoneLogin,getcodeLogin} from '../request/api/home'
export default createStore({
  state: {
    playList:[{
     al:{
      id: 161032929,
      name: "Hear Me Call Your Name",
      pic: 109951168437173860,
      picUrl: "https://p1.music.126.net/xP3ih_NmL9fuBvZr3KLfYw==/109951168437173861.jpg",
      pic_str: "109951168437173861"
     },
     id:2026820476
    }],
    playListIndex:0,
    isBtnShow:true, //播放按钮的显示
    isMusicDetail:false ,//歌曲详情页
    isLogin:false,//是否登录
    isFooterMusic:true, //是否显示底部组件
    token:'',//登录的token
    mvid:'' //视频的id
  },
  getters: {
  },
  mutations: {
    //更新播放按钮的状态
    updataBtnShow(state,value){
      state.isBtnShow=value
     },
     //更新歌曲列表
     updataPlayList(state,value){
      state.playList=value
      console.log(state.playList)
     },
     playSearchList(state,value){
      state.playList.push(value)
     },
     //修改歌曲下标
     updataMusicIndex(state,value){
      state.playListIndex=value
     },
     //歌曲详情页
     IsMusicDetail(state,value){
      state.isMusicDetail=!state.isMusicDetail
     },
     //判断用户是否登录
     updateLogin(state,value){
      state.isLogin=true
     },
     //保存用户的token
     updataToken(state,value){
      state.token=value,
      //进行持久化存储
      localStorage.setItem('token',state.token)
     },
     updataMvid(state,value){
      console.log('1',value)
       state.mvid=value
     }
  },
  actions: {
    //登录
    getLogin(context,value){
       getphoneLogin(value).then((res)=>{
        console.log('111',res)
        return res.code
       })
    },
    getCode(context,value){
     getcodeLogin(value).then((res)=>{
      console.log(res)
     })
    }
  },
  modules: {
  }
})
